package test;

import java.util.Arrays;
import java.util.Scanner;

public class QuestionOne {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), m = scanner.nextInt();
        double[] a =new double[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextDouble();
        }
        if(n <= m){
            double sum = 0;
            for(double x : a) sum += x;
            System.out.printf("%.1f\n", sum);
            return;
        }

        int k = n -m;
        if(k > n / 2){
            System.out.println(-1);
            return;
        }

        Double[][] dp = new Double[n+1][k+1];
        for (int i = 0; i <= n; i++) {
            Arrays.fill(dp[i], -1e14);
        }
        dp[0][0] = 0.0;

        for (int i = 1; i <= n ; i++) {
            for (int j = 0; j <= k ; j++) {
                if(dp[i-1][j] > -1e14){
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][j] + a[i-1]);
                }
                if(i >= 2 && j >= 1 && dp[i-2][j-1] > -1e14){
                    double merged = (a[i-2] + a[i-1]) / 2.0;
                    dp[i][j] = Math.max(dp[i][j], dp[i-2][j-1] + merged);
                }
            }
        }
        double ans = dp[n][k];
        if(ans < -1e14) System.out.println(-1);
        else System.out.printf("%.1f\n", ans);
    }
}
